<?php namespace Core\Myapp\Model;

use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Eloquent\Model;

abstract class Modelabstract extends Model
{
    protected $_data = array();
    private static  $driver = DB_DRIVER;

    private static $host = DB_HOST;

    private static $username = DB_USERNAME;

    private static $password = DB_PASSWORD;

    private static $database = DB_DATABASE;

    private static $charset = 'utf8';

    private static $collation = 'utf8_general_ci';

    private static $prefix = DB_PREFIX;

    public function __construct(){
        $capsule = new Capsule();
        $capsule->addConnection([
            'driver'   => self::$driver,
            'host'	   => self::$host,
            'username' => self::$username,
            'password' => self::$password,
            'database' => self::$database,
            'charset'  => self::$charset,
            'collation'=> self::$collation,
            'prefix' => self::$prefix
        ]);
        $capsule->bootEloquent();
    }
    public function __get($name)
    {
        return $this->_data[$name];
    }

    public function __set($name, $value)
    {
        $this->_data[$name] = $value;
        return $this;
    }
}